<template>

  <el-container>
    <el-aside width="200px">
      <menus :menuData="menuData"></menus>
    </el-aside>

    <el-container>
      <el-header><p>欢迎您，{{user.userName}}<a @click="logout" href="/">退出登陆</a></p>

      </el-header>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import menus from "../components/menus";
export default {
  name: "main",
  components:{
    menus
  },
  data(){
    return{
        user:null,
        menuData:[]
    }
  },
  methods: {
    getMenus() {
      this.$http.get("/woniuMenus/menus/"+this.user.userId).then(
          resp=>{
            console.log(resp);
            this.menuData = resp.data.object;
            console.log(this.menuData);
          }
      )
    },
    logout(){
      this.$http.get("/logout");
    },
    getUser(){
      this.$http.get("/woniuUser/getOne").then(resp=>{
        this.user=resp.data.object;
        this.getMenus();
      })
    }
  },
  created() {
    this.getUser();
  }
}
</script>

<style scoped>

</style>